/*
*  Texture.h
*  SypXIPhone
*
*  Created by Luv Khemani on 5/14/10.
*  Copyright 2010 Luv Khemani. All rights reserved.
*
*/


#pragma once
#ifndef SYPX_TEXTURE
#define SYPX_TEXTURE

#include "Types.h"
#include "Resource.h"

namespace SypX
{

	///Resource-Managed
	///Texture holds texture data and texture information
	class SYPXAPI Texture :	public Resource
	{
	public:
		///Default Texture constructor
		Texture(void);
		virtual ~Texture(void);
		///Loads a texture from a .png file. This is static in order to prevent Resource duplication
		static Texture* loadFromFile(const String& file);
		///Loads texture contents from a memory buffer
		///@par width,height of the texture
		///@par format Format of the data passed in
		///@par internalFormat Internal Format of how the texture should be stored
		///@par data A pointer to the texture data
		//void loadFromMemory(UShort width, UShort height, TextureFormat format, TextureFormat internalFormat, unsigned char* data);
		///Called to allocate and submit texture data to GPU
		///Textures which are never drawn should not be submitted to GPU.
		void submitToGPU();
		///Returns the texture Width
		UInt getWidth();
		///Returns the texture Height
		UInt getHeight();
		///Returns the bytes per pixel
		UByte getBpp();
		///Returns the OpenGL handle to this texture
		UInt& getTexIDRef();
		///Returns a reference to the Data vector
		UByteArray& getDataRef();
		///Sets the texture Width (Should only be called by Texture file loaders prior to submitToGPU())
		void setWidth(UInt w);
		///Sets the texture Height (Should only be called by Texture file loaders prior to submitToGPU())
		void setHeight(UInt h);
		///Sets the texture formats for the data and the internal GPU format
		///(Should only be called by Texture file loaders prior to submitToGPU())
		void setFormats(TextureFormat dataFormat, TextureFormat internalFormat);
		///Returns the internal texture format stored in GPU
		TextureFormat getInternalFormat();
		///Returns the data texture format held in RAM
		TextureFormat getDataFormat();
	protected:
		TextureFormat texFormat;//The data texture format in RAM
		TextureFormat internalTexFormat;//The data texture format in GPU
		UInt width;
		UInt height;
		UByteArray data;
		///Bytes per pixel
		UByte bpp;
		///Texture ID usually allocated by OpenGL
		UInt texID;			
	private:		


	};

}
#endif